<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .widthF {
            width: 300px;
            height: 300px;
            background: red;
        }

        .widthS {
            width: 100px;
            height: 100px;
            background: gray;
        }

        .father_1 {
            /*将父元素类的行内元素水平居中*/
            text-align: center;
            /*行高要等于父元素的高度*/
            line-height: 300px;
        }

        .son_1 {
            display: inline-block;
            /*垂直方向居中*/
            vertical-align: middle;
            /*不设置为初始值，行高默认继承父元素的行高*/
            line-height: initial;
        }
    </style>
</head>

<body>
    <!--将子元素设置为行内元素，可以使用行内元素的属性-->
    <div class="father_1 widthF">
        <div class="son_1 widthS">
            <span>6</span>
        </div>
    </div>

</body>

</html>